﻿using AutoMapper;
using Modules;
using PmSoft;

namespace AppWebApi.Models.Dtos
{
    public class ProjectPositionDto
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public int ProjectId { get; set; }
        /// <summary>
        /// WGS84 纬度
        /// </summary>
        public decimal Lat { get; set; }
        /// <summary>
        /// WGS84 经度
        /// </summary>
        public decimal Lng { get; set; }
        /// <summary>
        /// 考勤范围
        /// </summary>
        public int AttendanceScope { get; set; }
        /// <summary>
        /// 详细地址
        /// </summary>
        public string Address { get; set; }
    }

    public static partial class ProjectPositionExceptions
    {
        public static ProjectPositionDto AsDto(this ProjectPosition projectPosition)
        {

            return ServiceAccessor.GetService<IMapper>().Map(projectPosition, new ProjectPositionDto());
        }

        public static IEnumerable<ProjectPositionDto> AsDtos(this IEnumerable<ProjectPosition> projectPositions)
        {
            List<ProjectPositionDto> dtos = new();
            foreach (var item in projectPositions)
            {
                dtos.Add(item.AsDto());
            }
            return dtos;
        }
    }
}
